package com.vgemv.jsutilitysdk.timesta;

import android.util.Log;

public class JsTimeStaManager {
    private static String TAG = "JsTimeStaManager";
    public static long startTime;
    public static long stepStartTime;
    public static long stepEndTime;
    public static long stopTime;
    public static String mMissionName;
    public static void startSta(String missonName) {
        startTime = System.currentTimeMillis();
        stepStartTime = startTime;
        mMissionName = missonName == null ? "" : missonName;
    }

    /**
     * 统计到开始时间到当前时间的耗时.
     */
    public static long step(String actionName) {
        stepEndTime = System.currentTimeMillis();
        long duration = stepEndTime - stepStartTime;
        Log.d(TAG,String.format("action %s cost time: %d ms",actionName,duration));
        stepStartTime = stepEndTime;
        return duration;
    }

    public static long stopSta(String actionName) {
        stepEndTime = stopTime = System.currentTimeMillis();
        long durationTotal = stopTime - startTime;
        long duration = stepEndTime - stepStartTime;
        Log.d(TAG,String.format("action %s cost time: %d ms",actionName,duration));
        Log.d(TAG,String.format("action %s cost time: %d ms",mMissionName,durationTotal));
        return duration;
    }
}
